﻿cmake_minimum_required(VERSION 2.8)
project(libtiff)
file(GLOB lib_srcs *.c)
file(GLOB lib_hdrs tiff*.h)
set(CMAKE_DEBUG_POSTFIX "D")
list(APPEND lib_libs ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} ${LIBLZMA_LIBRARIES})
include_directories(${ZLIB_INCLUDE_DIRS} ${JPEG_INCLUDE_DIRS} ${LIBLZMA_INCLUDE_DIRS} ${LIBLZMA_SOURCE_DIR}/api)
message(STATUS "${lib_libs}")

if(MSVC)
  list(APPEND lib_srcs ${PROJECT_NAME}.def)
endif()
add_library(${PROJECT_NAME} SHARED ${lib_srcs} ${lib_hdrs})
target_link_libraries(${PROJECT_NAME} ${lib_libs})
install(FILES ${lib_hdrs} DESTINATION include)
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib)
install(EXPORT ${PROJECT_NAME}-targets DESTINATION lib/cmake FILE ${PROJECT_NAME}-config.cmake)

if(BUILD_STATIC)
  add_library(${PROJECT_NAME}S STATIC ${lib_srcs} ${lib_asms} ${lib_objs})
  install(TARGETS ${PROJECT_NAME}S EXPORT ${PROJECT_NAME}S-targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib)
  install(EXPORT ${PROJECT_NAME}S-targets DESTINATION lib/cmake FILE ${PROJECT_NAME}S-config.cmake)
endif()
